package main

import (
	"log"
	"longmen/server/config/global"
	"longmen/server/internal/rpc/tencentim/room_event"
	"longmen/server/internal/services/worker/crontab"
	"longmen/server/internal/services/worker/init_perform"
	"longmen/server/internal/services/worker/internal"
	"longmen/server/pkg/grpc_client"
)

func main() {
	global.AppName = "worker"
	global.Initialize("../../../config/app.properties")
	global.ReloadAutoLive("../../../config/auto_live_config.json")
	global.InitMQ()
	global.InitPublisher()
	err := global.InitElasticSearch()
	if err != nil {
		log.Fatalf("%s", err.Error())
	}
	grpc_client.InitTimGrpc()
	grpc_client.InitGrpc()
	guessSettleInterval := global.Config.GetInt("models_guess.interval") //多久算一次奖
	if guessSettleInterval == 0 {
		guessSettleInterval = 10
	}
	go crontab.SettleGuessTimer(guessSettleInterval)
	go crontab.SendGuessUpdate()
	// todo 在各環境初次運行以後可以關閉
	//crontab.PutUserBloomInit()
	//运行启动时补数据
	//crontab.IpStats()
	go room_event.SyncRoomStatusAndHeat()
	crontab.PutUserBloomInit()

	crontab.PutAnchorBloomInit()
	//todo 上版前開啟
	init_perform.AddAnchorTagsFromTable() // 初始化關注主播標籤
	//init_perform.AddGameTagsFromTable()     // 初始化關注比賽標籤
	//go init_perform.AddMatchLiveNotifyTag() // 初始化 通知標籤

	//go internal.SubscribeImService()
	//go internal.Subscribe()
	//go internal.SubscribeAccountFlow()
	////go internal.SubscribeStatUserChannel()
	go crontab.CrontabInit()
	//go internal.SubscribeActivityChannel()
	go internal.MqGiftConsumer()
	go internal.QueryRedisGiftToMqOmit()
	go internal.LiveDbToRedis()
	go crontab.MatchSync()
	crontab.AutoChat()
	// pyroscope.InitPyroScope("worker")

	select {}
}
